home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / opengl / xlib / glxvis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.3 KB  |  93 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <GL/glx.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20.  
  21. static const char* ClassOf(int c)
  22. {
  23.     switch (c) {
  24.       case StaticGray:    return "StaticGray";
  25.       case GrayScale:    return "GrayScale";
  26.       case StaticColor:    return "StaticColor";
  27.       case PseudoColor:    return "PseudoColor";
  28.       case TrueColor:    return "TrueColor";
  29.       case DirectColor:    return "DirectColor";
  30.       default:        return "unknown";
  31.     }
  32. }
  33.  
  34. static void DumpGLXProperties(Display *dpy, XVisualInfo *vi)
  35. {
  36.     int bufferSize, level, rgba, doubleBuffer, stereo, auxBuffers,
  37.         redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize,
  38.         accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
  39.  
  40.     glXGetConfig(dpy, vi, GLX_BUFFER_SIZE, &bufferSize);
  41.     glXGetConfig(dpy, vi, GLX_LEVEL, &level);
  42.     glXGetConfig(dpy, vi, GLX_RGBA, &rgba);
  43.     glXGetConfig(dpy, vi, GLX_DOUBLEBUFFER, &doubleBuffer);
  44.     glXGetConfig(dpy, vi, GLX_STEREO, &stereo);
  45.     glXGetConfig(dpy, vi, GLX_AUX_BUFFERS, &auxBuffers);
  46.     glXGetConfig(dpy, vi, GLX_RED_SIZE, &redSize);
  47.     glXGetConfig(dpy, vi, GLX_GREEN_SIZE, &greenSize);
  48.     glXGetConfig(dpy, vi, GLX_BLUE_SIZE, &blueSize);
  49.     glXGetConfig(dpy, vi, GLX_ALPHA_SIZE, &alphaSize);
  50.     glXGetConfig(dpy, vi, GLX_DEPTH_SIZE, &depthSize);
  51.     glXGetConfig(dpy, vi, GLX_STENCIL_SIZE, &stencilSize);
  52.     glXGetConfig(dpy, vi, GLX_ACCUM_RED_SIZE, &accumRedSize);
  53.     glXGetConfig(dpy, vi, GLX_ACCUM_GREEN_SIZE, &accumGreenSize);
  54.     glXGetConfig(dpy, vi, GLX_ACCUM_BLUE_SIZE, &accumBlueSize);
  55.     glXGetConfig(dpy, vi, GLX_ACCUM_ALPHA_SIZE, &accumAlphaSize);
  56.  
  57.     printf("    bufferSize=%d level=%d rgba=%d doubleBuffer=%d stereo=%d\n",
  58.        bufferSize, level, rgba, doubleBuffer, stereo);
  59.     printf("    rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
  60.        redSize, greenSize, blueSize, alphaSize);
  61.     printf("    auxBuffers=%d depthSize=%d stencilSize=%d\n",
  62.        auxBuffers, depthSize, stencilSize);
  63.     printf("    accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
  64.        accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize);
  65. }
  66.  
  67. int main()
  68. {
  69.     XVisualInfo match, *vi;
  70.     Display *dpy;
  71.     int found;
  72.  
  73.     dpy = XOpenDisplay(0);
  74.     if (!dpy) {
  75.     fprintf(stderr, "Can't connect to display \"%s\"\n", getenv("DISPLAY"));
  76.     return -1;
  77.     }
  78.  
  79.     match.screen = DefaultScreen(dpy);
  80.     vi = XGetVisualInfo(dpy, VisualScreenMask, &match, &found);
  81.     while (--found >= 0) {
  82.     int value;
  83.     glXGetConfig(dpy, vi, GLX_USE_GL, &value);
  84.     if (value) {
  85.         printf("Visual ID: %x  depth=%2d  class=%s\n",
  86.            vi->visualid, vi->depth, ClassOf(vi->class));
  87.         DumpGLXProperties(dpy, vi);
  88.     }
  89.     vi++;
  90.     }
  91.     return 0;
  92. }
  93.